package com.slz3.business.module.goodsManagement.gooInWarehouse.service;

import com.slz3.business.frame.module.Repositorys;
import com.slz3.business.module.goodsManagement.gooInWarehouse.domain.GooInWarehouse;
import com.slz3.business.module.goodsManagement.gooInWarehouse.domain.GooInWarehouseFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Slf4j
@Service
public class GooInWarehouseTransactionalServiceImpl implements GooInWarehouseTransactionalService {

    @Override
    public GooInWarehouse modify(GooInWarehouse gooInWarehouseNew) {
        Repositorys.gooInWarehouse.test();
        Repositorys.gooInWarehouse.save(GooInWarehouseFactory.initBaseFields());
        System.err.println(1 / 0);
        gooInWarehouseNew.setLastModifyTime(LocalDateTime.now());
        return Repositorys.gooInWarehouse.saveAndFlush(gooInWarehouseNew);
    }

    @Override
    public List<GooInWarehouse> batchModify(List<GooInWarehouse> gooInWarehouseList) {
        return Repositorys.gooInWarehouse.saveAll(gooInWarehouseList);
    }
}
